<template>
  <div class="smartList">
    <div class="pageList">
      <div class="count">
        <span class="number">
          <span class="return" @click="returnHome">
            <span>
              <img
                src="../../assets/images/return2.png"
                width="15px"
                height="20px"
              /> </span
            >返回首页
          </span>
          |&nbsp;&nbsp;<span style="font-size: 18px; color: #f7f7f8"
            >{{ total }}&nbsp;</span
          >件  &nbsp;&nbsp;{{ smartSearchValue }}
        </span>
      </div>
      <Pages :allDate="data" :pageSize="pageSize" :total="total"></Pages>
    </div>
  </div>
</template>

<script>
import Pages from "@/components/Pages.vue";
import { smartSearch } from "@/api/all";
import { mapState, mapMutations } from "vuex";
import { Message } from "element-ui";
export default {
  components: {
    Pages,
  },
  props: {
    smartSearchValue: {},
  },
  data() {
    return {
      data: [],
      total: 0, //总条数
      pageSize: 30, //每页多少条
    };
  },
  mounted() {
    this.init();
  },
  watch:{
    smartSearchValue(newVal, oldVal){
      this.smartSearchValue=newVal
      this.init()
    }
  },
  methods: {
    ...mapMutations("app", [
      "setLoading","setTitle"
    ]),
    async init() {
      this.setLoading(true)
      this.setTitle("数据加载中")
        let params={
            smartSearchValue:this.smartSearchValue.trim()
        }
        await smartSearch(params)
        .then((res) => {
          if (res.data.code === 200) {
            this.data=res.data.data.relicList;
            this.total = this.data.length;
            this.setLoading(false)
          }
        })
        .catch((error) => {
            Message.error("检索失败")
            this.setLoading(false)
        });

    },
    returnHome() {
      this.$bus.$emit("smartSearch", "");
    },
  },
};
</script>

<style scoped>
.smartList {
  min-height: 100vh;
}
.pageList {
  min-height: 90vh;
}
.count {
  font-size: 25px;
  background: #5f806f;
  display: flex;
  height: 70px;
  width: 100%;
  border-bottom: 1px solid #fff;
  margin-top: 20px;
  justify-content: space-between;
  align-content: space-between;
}
.number {
  color: #f2f3f4;
  font-size: 20px;
  padding-left: 20px;
  margin-top: 15px;
}
.vue-waterfall-column {
  width: 294px !important;
}
.return {
  color: #f2f3f4;
}
.return {
  margin-right: 10px;
}
.return span {
  vertical-align: middle;
}
</style>